cmake_minimum_required(VERSION 3.18)

project(app)

if(NOT TARGET Protobuf)
  find_package(Protobuf CONFIG REQUIRED)
endif()

if(NOT TARGET gRPC)
  find_package(gRPC CONFIG REQUIRED)
endif()

include_directories(
  ${PROJECT_SOURCE_DIR}/include
)

add_executable(
  server 
  ${PROJECT_SOURCE_DIR}/src/server.cpp 
  ${PROJECT_SOURCE_DIR}/src/hello.pb.cc
  ${PROJECT_SOURCE_DIR}/src/hello.grpc.pb.cc
)

add_executable(
  client 
  ${PROJECT_SOURCE_DIR}/src/client.cpp 
  ${PROJECT_SOURCE_DIR}/src/hello.pb.cc
  ${PROJECT_SOURCE_DIR}/src/hello.grpc.pb.cc
)

target_link_libraries(
  server
  PRIVATE 
  protobuf::libprotoc 
  protobuf::libprotobuf 
  protobuf::libprotobuf-lite
  gRPC::gpr 
  gRPC::grpc 
  gRPC::grpc++ 
  gRPC::grpc++_alts
)

target_link_libraries(
  client
  PRIVATE 
  protobuf::libprotoc 
  protobuf::libprotobuf 
  protobuf::libprotobuf-lite
  gRPC::gpr 
  gRPC::grpc 
  gRPC::grpc++ 
  gRPC::grpc++_alts
)